*###################################################################*
* Title: How the Pro-Beijing Media Influences Voters				*
* Author: Jay C. Kao												*
* Date: December 2, 2025											*
*###################################################################*
* 00_pre-processing script										    *	
*	1. Cleans raw survey data for both waves					    *	
*	2. Merges survey responses with browsing behavior			    *
*	3. Labels variables and values								    *	
*	4. Prepares analysis.dta for reproducing tables and figures     *
* 																	*
* IMPORTANT: Set your Working Directory to the root folder of       *
* the replication package before running this script.               *
* Example: cd "C:/Users/YourName/Desktop/Replication_Package"       *
*###################################################################*

*cd "C:/Users/YourName/Desktop/Replication_Package"

clear all
set more off

*###################*
*# Baseline SURVEY #*
*###################*

* Read from Data subfolder
import delimited "Data/baseline_cleaned.csv", case(preserve) encoding("UTF-8") clear

*Demographics

gen age = 2019 - (2006 - Q1)

gen female = (Q2 == 1) if !missing(Q2)

gen location="Jilong" 				if Q42==547
replace location="Taipei" 			if Q42==548
replace location="Xinbei" 			if Q42==549
replace location="Taoyuan" 			if Q42==550
replace location="Xinzhu City" 		if Q42==551
replace location="Taizhong" 		if Q42==552
replace location="Jiayi City" 		if Q42==553
replace location="Tainan" 			if Q42==554
replace location="Gaoxiong" 		if Q42==555
replace location="Xinzhu County" 	if Q42==556
replace location="Miaoli" 			if Q42==557
replace location="Zhanghua" 		if Q42==558
replace location="Nantou" 			if Q42==559
replace location="Yunlin" 			if Q42==560
replace location="Jiayi County" 	if Q42==561
replace location="Pindong" 			if Q42==562
replace location="Yilan" 			if Q42==563
replace location="Hualian" 			if Q42==564
replace location="Taidong" 			if Q42==565
replace location="Penghu" 			if Q42==566
replace location="Jinmen" 			if Q42==567
replace location="Lianjiang" 		if Q42==588

gen special_municipality = inlist(location, "Taipei", "Xinbei", "Taoyuan", "Taizhong", "Tainan", "Gaoxiong") if !missing(location)

gen edu = Q43
recode edu 18=1 19=2 20=3 21=4 22=5 23=6

gen full_time = 		(Q44 == 46) if !missing(Q44)

gen married = 			(Q45 == 1) if !missing(Q45)

gen income_cat = 		Q46

gen father_islander = 	(Q47 == 2) if !missing(Q47)

gen taoism = 			(Q48 == 3) if !missing(Q48)

gen identity = 			Q49

gen nwpaper_pref_apple = 0
replace nwpaper_pref_apple = 1 if strpos(Q38, "43")

gen sanlih_show = 		5 - Q39_2

* Conditions
gen control = (conditions==1) if conditions !=4
gen placebo = (conditions==2) if conditions !=4
gen treatment = (conditions==3) if conditions !=4
gen china_times = (conditions==4)


* Political predisposition
gen partyid = 			Q5 - 190 if inrange(Q5, 191, 200) 
replace partyid = 		Q5b if inrange(Q5b, 1, 10) 
recode partyid 	(1 3 4 = 1) (8 9 10 = 2) (2 5 6 7 = 3), gen(spectrum)

gen pan_blue 	= (spectrum==1) if !missing(spectrum)
gen independent = (spectrum==2) if !missing(spectrum)
gen pan_green 	= (spectrum==3) if !missing(spectrum)

gen president_2016 = Q9
gen president_2016_voted = inlist(Q9, 1, 2, 3) if !missing(Q9)

gen president_2012 = Q10
gen president_2012_voted = inlist(Q10, 1, 2, 3) if !missing(Q10)


* Vote choice (baseline)
gen turnout_w1 = (Q6 == 1) if !missing(Q6)

gen pres_vote_w1 = Q7
gen vote_han_w1       = (Q7 == 1) if !missing(Q7)
gen vote_tsai_w1      = (Q7 == 2) if !missing(Q7)
gen vote_song_w1      = (Q7 == 3) if !missing(Q7)
gen vote_undecided_w1 = (Q7 == 4) if !missing(Q7)

* Candidate evaluation (baseline)
gen han_thermo_w1 = Q13
gen tsai_thermo_w1 = Q14
gen song_thermo_w1 = Q15
gen relative_thermo_w1 = han_thermo_w1 - tsai_thermo_w1

* Attitudes toward China (baseline)
gen china_thermo_w1 = Q16
gen ch_econ_inf_w1 = Q17
recode ch_econ_inf_w1 1=4 2=3 3=2 4=1
gen ch_threat_w1 = Q18
gen ch_usa_power_w1 = Q19
recode ch_usa_power_w1 1=4 2=3 3=2 4=1
gen strait_relation = Q20
gen strait_trade_w1 = Q21
gen xidada_w1 = Q22
gen hk_protest_w1 = Q32
recode hk_protest_w1 1=5 2=4 4=2 5=1
gen hk_radical_w1 = Q33
recode hk_radical_w1 1=5 2=4 4=2 5=1
egen prc_index_w1 = rmean(china_thermo_w1 ch_econ_inf_w1 ///
ch_threat_w1 ch_usa_power_w1 strait_trade_w1 xidada_w1 hk_protest_w1 hk_radical_w1)


* Political interest (baseline)
gen interest_campaign_w1 = Q25
recode interest_campaign_w1 78=1 79=2 80=3 81=4 82=5

gen concern_election_outcome_w1 = Q26
recode concern_election_outcome_w1 55=1 56=2 57=3 58=4 59=5

gen get_tv_news_w1 = Q36a
gen get_nwpaper_news_w1 = Q36b
gen get_social_media_news_w1 = Q36c
gen get_web_news_w1 = Q36d
recode get_tv_news_w1 1=4 2=3 3=2 4=1
recode get_nwpaper_news_w1 1=4 2=3 3=2 4=1
recode get_social_media_news_w1 1=4 2=3 3=2 4=1
recode get_web_news_w1 1=4 2=3 3=2 4=1
egen overall_polinews_consumption_w1 = rmean(get_tv_news_w1 get_nwpaper_news_w1 ///
get_social_media_news_w1 get_web_news_w1)

gen pnews_days_w1 = Q37


* Save to Data subfolder
save "Data/baseline.dta", replace


*##################*
*# Endline SURVEY #*
*##################*

* Read from Data subfolder
import delimited "Data/endline_cleaned.csv", case(preserve) encoding("UTF-8") clear

gen wave2 = 1

* Vote choice (endline)

gen turnout_w2 = (Q1 == 4) if !missing(Q1)

gen pres_vote_w2 = Q1YA
recode pres_vote_w2 12=1 13=2 14=3 15=4
gen vote_han_w2       = (Q1YA == 1) if !missing(Q1YA)
gen vote_tsai_w2      = (Q1YA == 2) if !missing(Q1YA)
gen vote_song_w2      = (Q1YA == 3) if !missing(Q1YA)

* Candidate evaluation (endline)
gen han_thermo_w2 = Q4_1
gen tsai_thermo_w2 = Q5_1
gen song_thermo_w2 = Q6_1
gen relative_thermo_w2 = han_thermo_w2 - tsai_thermo_w2

* Attitudes toward China (endline)
gen china_thermo_w2 = Q7_1

gen ch_econ_inf_w2 = Q8
recode ch_econ_inf_w2 1=4 2=3 3=2 4=1

gen ch_threat_w2 = Q9

gen ch_usa_power_w2 = Q10
recode ch_usa_power_w2 1=4 2=3 3=2 4=1

gen strait_trade_w2 = Q12

gen xidada_w2 = Q13

* note: reversed response order in endline
gen hk_protest_w2 = Q25
gen hk_radical_w2 = Q26

egen prc_index_w2 = rmean(china_thermo_w2 ch_econ_inf_w2 ///
ch_threat_w2 ch_usa_power_w2 strait_trade_w2 xidada_w2 hk_protest_w2 hk_radical_w2)


* Political interest (endline)
gen interest_campaign_w2 = Q18
recode interest_campaign_w2 78=1 79=2 80=3 81=4 82=5

gen concern_election_outcome_w2 = Q19
recode concern_election_outcome_w2 55=1 56=2 57=3 58=4 59=5

gen get_tv_news_w2 = Q29A
gen get_nwpaper_news_w2 = Q29B
gen get_social_media_news_w2 = Q29C
gen get_web_news_w2 = Q29D
recode get_tv_news_w2 1=4 2=3 3=2 4=1
recode get_nwpaper_news_w2 1=4 2=3 3=2 4=1
recode get_social_media_news_w2 1=4 2=3 3=2 4=1
recode get_web_news_w2 1=4 2=3 3=2 4=1
egen overall_polinews_consumption_w2 = rmean(get_tv_news_w2 get_nwpaper_news_w2 get_social_media_news_w2 get_web_news_w2)

gen pnews_days_w2 = Q30


* Mechanisms

* Psychological reactance
gen rec_threat = Q37A
gen rec_decision = Q37B
gen rec_manipulate = Q37C
gen rec_pressure = Q37D
egen reactance = rmean(rec_threat rec_decision rec_manipulate rec_pressure)

* Cognitive reaction
gen website_quality = Q38
gen website_strength = Q39

* Emotional reaction
gen angry = Q40_1
gen enthusiastic = Q40_2
gen disgusting = Q40_3
gen hopeful = Q40_4
egen positive_emotion = rmean(enthusiastic hopeful)
egen negative_emotion = rmean(angry disgusting)

* Red media
gen ct_rmedia = Q41

* List experiment
gen list_exp_control = Q42Control
recode list_exp_control 93=0 94=1 95=2 96=3 97=4

gen list_exp_treatment = Q42Experiment
recode list_exp_treatment 144=0 145=1 146=2 147=3 148=4 149=5

gen list_exp_group = . 
replace list_exp_group = 0 if list_exp_control!=.
replace list_exp_group = 1 if list_exp_treatment!=.

gen itemcount = .
replace itemcount= list_exp_control if itemcount==.
replace itemcount= list_exp_treatment if itemcount==.

* Save to Data subfolder
save "Data/endline.dta", replace


*###############*
*# MERGE WAVES #*
*###############*

use "Data/baseline.dta", clear
sort gid
merge m:1 gid using "Data/endline.dta", force

replace wave2=0 if wave2==.
drop _merge

* Create outcome variables
gen turnout_change 				= turnout_w2 - turnout_w1
gen vote_han_change 			= vote_han_w2 - vote_han_w1
gen vote_tsai_change 			= vote_tsai_w2 - vote_tsai_w1
gen vote_song_change 			= vote_song_w2 - vote_song_w1
gen relative_thermo_change 		= relative_thermo_w2 - relative_thermo_w1
gen china_thermo_change 		= china_thermo_w2 - china_thermo_w1
gen ch_econ_inf_change 			= ch_econ_inf_w2 - ch_econ_inf_w1
gen ch_threat_change 			= ch_threat_w2 - ch_threat_w1
gen ch_usa_power_change 		= ch_usa_power_w2 - ch_usa_power_w1
gen strait_trade_change 		= strait_trade_w2 - strait_trade_w1
gen xidada_change 				= xidada_w2 - xidada_w1
gen hk_protest_change 			= hk_protest_w2 - hk_protest_w1
gen hk_radical_change 			= hk_radical_w2 - hk_radical_w1
gen prc_index_change			= prc_index_w2 - prc_index_w1

* Save to Data subfolder
save "Data/panel.dta", replace


* Merge with browsing tracking data
import delimited "Data/tracking_cleaned.csv", encoding("UTF-8") clear
save "Data/tracking.dta", replace

use "Data/panel.dta", clear
sort gid
merge m:1 gid using "Data/tracking.dta", force
drop _merge

gen full_complier = (avg_browsing>=180) 	if avg_browsing!=.
replace full_complier = 0						if control == 1
replace full_complier  = 0 						if placebo == 1
replace full_complier = 0 						if avg_browsing==. & (placebo==1 | treatment==1 )

gen min_complier = (avg_browsing>=60) 	if avg_browsing!=.
replace min_complier = 0						if control == 1
replace min_complier = 0	 					if placebo == 1
replace min_complier = 0 						if avg_browsing==. & (placebo==1 | treatment==1 )


*###############################*
*# LABELS VARIABLES AND VALUES #*
*###############################*

label var gid 					"Unique respondent ID"
label var wave2 				"Survey wave indicator"
label var age 					"Age"
label var female 				"Gender (female=1)"
label var location				"Current residence"
label var special_municipality 	"Lives in special municipality (yes=1)"
label var edu 					"Highest education level"
label var full_time 			"Full-time employment (yes=1)"
label var married 				"Marital status"
label var income_cat 			"Monthly household income"
label var father_islander 		"Ethnic background (minnan=1)"
label var taoism 				"Religion (taoism=1)"

* Political predisposition
label var partyid				"Partisan leaning"
label var spectrum 				"Political predisposition"
label var pan_blue 				"spectrum==Pan-Blue"
label var independent 			"spectrum==Nonpartisan"
label var pan_green 			"spectrum==Pan-Green"

label var president_2016		"Vote choice in 2016 election"
label var president_2016_voted 	"Turnout in 2016 election"
label var president_2012 		"Vote choice in 2012 election"
label var president_2012_voted 	"Turnout in 2012 election"

label var nwpaper_pref_apple 	"Prefers Apple Daily for news"
label var sanlih_show 			"Preference ranking for SET New Taiwan Refueling"

label var strait_relation 		"Cross-strait political position"
label var identity 				"National identity"

* -------------------------
* Baseline (Wave 1)
* -------------------------
label var turnout_w1 			"Turnout intention (baseline)"
label var pres_vote_w1 			"Vote intention (baseline)"
label var vote_han_w1 			"pres_vote_w1==Han (baseline)"
label var vote_tsai_w1 			"pres_vote_w1==Tsai (baseline)"
label var vote_song_w1 			"pres_vote_w1==Soong (baseline)"
label var vote_undecided_w1 	"pres_vote_w1==undecided (baseline)"

label var han_thermo_w1 		"Favorability: Han (baseline)"
label var tsai_thermo_w1 		"Favorability: Tsai (baseline)"
label var song_thermo_w1 		"Favorability: Soong (baseline)"
label var relative_thermo_w1 	"Han-Tsai favorability (baseline)"

label var china_thermo_w1 		"Favorability toward PRC (baseline)"
label var ch_econ_inf_w1 		"Impact of PRC economic growth (baseline)"
label var ch_threat_w1 			"Perceived PRC military threat (baseline)"
label var ch_usa_power_w1 		"Belief PRC will surpass US in 10 years (baseline)"
label var strait_trade_w1 		"Cross-strait trade preference (baseline)"
label var xidada_w1 			"Trust in Xi's global leadership (baseline)"
label var hk_protest_w1 		"Support for HK protests (baseline)"
label var hk_radical_w1 		"Justification for HK radical tactics (baseline)"
label var prc_index_w1 			"Composite PRC index (baseline)"

label var interest_campaign_w1 				"Interest in election campaign (baseline)"
label var concern_election_outcome_w1 		"Concern about who wins election (baseline)"
label var pnews_days_w1 					"Daily election news consumption (baseline)"
label var get_tv_news_w1				"Frequency: tv news (baseline)"
label var get_nwpaper_news_w1			"Frequency: nwpaper news (baseline)"
label var get_social_media_news_w1		"Frequency: social media news (baseline)"
label var get_web_news_w1			"Frequency: news site (baseline)"
label var overall_polinews_consumption_w1 	"Overall news consumption (baseline)"

* -------------------------
* Experimental Assignment
* -------------------------
label var conditions 			"Condition"
label var treatment 			"conditions==Treatment"
label var placebo 				"conditions==Placebo"
label var control 				"conditions==Control"
label var china_times 			"conditions==Existing"

label var avg_browsing 			"Average daily browsing time (seconds)"
label var full_complier 		"Full complier (≥180 seconds)"
label var min_complier 			"Minimum complier (≥60 seconds)"

* -------------------------
* Endline (Wave 2)
* -------------------------
label var turnout_w2 			"Actual turnout (endline)"
label var pres_vote_w2 			"Actual presidential vote (endline)"
label var vote_han_w2 			"pres_vote_w2==Han (endline)"
label var vote_tsai_w2 			"pres_vote_w2==Tsai (endline)"
label var vote_song_w2 			"pres_vote_w2==Soong (endline)"

label var han_thermo_w2 		"Favorability: Han (endline)"
label var tsai_thermo_w2 		"Favorability: Tsai (endline)"
label var song_thermo_w2 		"Favorability: Soong (endline)"
label var relative_thermo_w2 	"Han-Tsai favorability (endline)"

label var china_thermo_w2 		"Favorability toward PRC (endline)"
label var ch_econ_inf_w2 		"Impact of PRC economic growth (endline)"
label var ch_threat_w2 			"Perceived PRC military threat (endline)"
label var ch_usa_power_w2 		"Belief PRC will surpass US in 10 years (endline)"
label var strait_trade_w2 		"Cross-strait trade preference (endline)"
label var xidada_w2 			"Trust in Xi's global leadership (endline)"
label var hk_protest_w2 		"Support for HK protests (endline)"
label var hk_radical_w2 		"Justification for HK radical tactics (endline)"
label var prc_index_w2 			"Composite PRC index (endline)"

label var interest_campaign_w2 				"Interest in election campaign (endline)"
label var concern_election_outcome_w2 		"Concern about who wins election (endline)"
label var pnews_days_w2 					"Daily election news consumption (endline)"
label var get_tv_news_w2				"Frequency: tv news (endline)"
label var get_nwpaper_news_w2			"Frequency: nwpaper news (endline)"
label var get_social_media_news_w2		"Frequency: social media news (endline)"
label var get_web_news_w2			"Frequency: news site (endline)"
label var overall_polinews_consumption_w2 	"Overall news consumption (endline)"

* -------------------------
* Mechanisms (Wave 2)
* -------------------------
label var website_quality 		"Perceived website quality"
label var website_strength 		"Argument strength in website news article"
label var positive_emotion 		"Positive emotions after viewing website"
label var negative_emotion 		"Negative emotions after viewing website"
label var reactance 			"Psychological reactance to website content"

label var ct_rmedia 			"Perception that CT is Red Media"

label var list_exp_group 		"List experiment group (treatment==1)"
label var itemcount 			"List experiment item count"

* -------------------------
* Change Scores
* -------------------------
label var turnout_change 			"Change in turnout"
label var vote_han_change 			"Change in Han support"
label var vote_tsai_change 			"Change in Tsai support"
label var vote_song_change 			"Change in Soong support"
label var relative_thermo_change 	"Change in Han-Tsai relative favorability"

label var china_thermo_change 		"Change in favorability toward PRC"
label var ch_econ_inf_change 		"Change in perceived PRC economic impact"
label var ch_threat_change 			"Change in perceived PRC military threat"
label var ch_usa_power_change 		"Change in belief PRC will surpass US"
label var strait_trade_change 		"Change in cross-strait trade preference"
label var xidada_change 			"Change in trust in Xi's global leadership"
label var hk_protest_change 		"Change in support for HK protests"
label var hk_radical_change 		"Change in justification for HK radical tactics"
label var prc_index_change 			"Change in PRC index score"



* B. Value Labels
label define female_lbl 0 "Male" 1 "Female"
label values female female_lbl

label define specialmuni_lbl 0 "No" 1 "Yes"
label values special_municipality specialmuni_lbl

label define fulltime_lbl 0 "Part-time/Other" 1 "Full-time"
label values full_time fulltime_lbl

label define married_lbl 0 "No" 1 "Yes"
label values married married_lbl

label define father_lbl 0 "Other" 1 "Minnan Taiwanese"
label values father_islander father_lbl

label define taoism_lbl 0 "Other" 1 "Taoism"
label values taoism taoism_lbl

label define edu_lbl ///
    0 "No school" ///
    1 "Primary school" ///
    2 "Middle school" ///
    3 "High school" ///
    4 "Professional college" ///
    5 "University" ///
    6 "Graduate program+"
label values edu edu_lbl

label define income_lbl ///
    1 "<27,000" ///
    2 "27,001–38,000" ///
    3 "38,001–49,000" ///
    4 "49,001–59,000" ///
    5 "59,001–69,000" ///
    6 "69,001–80,000" ///
    7 "80,001–92,000" ///
    8 "92,001–109,000" ///
    9 "109,001–140,000" ///
    10 "140,001–190,000" ///
    11 "190,001–240,000" ///
    12 "240,001–290,000" ///
    13 "290,001–340,000" ///
    14 ">340,000"
label values income_cat income_lbl

label define party_lbl ///
	1 "KMT" 2 "DPP" 3 "New Party" ///
	4 "People First Party" 5 "Taiwan Solidarity Party" ///
	6 "Green Party" 7 "New Power Party" 8 "Taiwan People's Party" ///
	9 "Tree Party" 10 "None of the above"  
label values partyid party_lbl
	
label define spectrum_lbl ///
    1 "Pan-Blue" ///
    2 "Nonpartisan" ///
    3 "Pan-Green"
label values spectrum spectrum_lbl

label define yesno_lbl 0 "No" 1 "Yes"
label values pan_blue yesno_lbl
label values independent yesno_lbl
label values pan_green yesno_lbl
label values president_2016_voted yesno_lbl
label values president_2012_voted yesno_lbl

label define pv2012_lbl ///
    1 "KMT" ///
    2 "DPP" ///
    3 "PFP" ///
    4 "Did not vote" ///
    5 "Below age 20" ///
    6 "Don't remember"
label values president_2016 pv2012_lbl
label values president_2012 pv2012_lbl

label define apple_lbl 0 "Other" 1 "Apple Daily"
label values nwpaper_pref_apple apple_lbl

label define sanlih_lbl ///
    1 "Least preferred" ///
    2 "Third preferred" ///
    3 "Second preferred" ///
    4 "Most preferred"
label values sanlih_show sanlih_lbl

label define strait_lbl ///
    1 "Unify immediately" ///
    2 "Independence immediately" ///
    3 "Status quo → Unify" ///
    4 "Status quo → Independence" ///
    5 "Status quo → Decide later" ///
    6 "Status quo indefinitely"
label values strait_relation strait_lbl

label define identity_lbl ///
    1 "Taiwanese" ///
    2 "Chinese" ///
    3 "Both"
label values identity identity_lbl

label define cond_lbl ///
    1 "Control" ///
    2 "Placebo" ///
    3 "Treatment" ///
    4 "Existing"

label values conditions cond_lbl
label values control yesno_lbl
label values placebo yesno_lbl
label values treatment yesno_lbl
label values china_times yesno_lbl
label values full_complier yesno_lbl
label values min_complier yesno_lbl

label values turnout_w1 yesno_lbl
label values turnout_w2 yesno_lbl

label define vote_lbl ///
    1 "Han" ///
    2 "Tsai" ///
    3 "Soong" ///
    4 "Undecided / Null"

label values pres_vote_w1 vote_lbl
label values pres_vote_w2 vote_lbl

label values vote_han_w1 yesno_lbl
label values vote_han_w2 yesno_lbl
label values vote_tsai_w1 yesno_lbl
label values vote_tsai_w2 yesno_lbl
label values vote_song_w1 yesno_lbl
label values vote_song_w2 yesno_lbl

label define undecided_lbl 0 "Has vote intention" 1 "Undecided"
label values vote_undecided_w1 undecided_lbl

label define econ_lbl ///
    1 "Very negative" ///
    2 "Somewhat negative" ///
    3 "Fairly positive" ///
    4 "Very positive"
label values ch_econ_inf_w1 econ_lbl
label values ch_econ_inf_w2 econ_lbl

label define threat_lbl ///
    1 "Major threat" ///
    2 "Minor threat" ///
    3 "No threat"
label values ch_threat_w1 threat_lbl
label values ch_threat_w2 threat_lbl

label define power_lbl ///
    1 "Definitely won't" ///
    2 "Probably won't" ///
    3 "Probably will" ///
    4 "Definitely will"
label values ch_usa_power_w1 power_lbl
label values ch_usa_power_w2 power_lbl

label define trade_lbl ///
    1 "Greatly reduce" ///
    2 "Slightly reduce" ///
    3 "Maintain" ///
    4 "Slightly increase" ///
    5 "Greatly increase"
label values strait_trade_w1 trade_lbl
label values strait_trade_w2 trade_lbl

label define xi_lbl ///
    1 "Strongly distrust" ///
    2 "Somewhat distrust" ///
    3 "Somewhat trust" ///
    4 "Strongly trust"
label values xidada_w1 xi_lbl
label values xidada_w2 xi_lbl

label define hkpro_lbl ///
    1 "Strongly support" ///
    2 "Somewhat support" ///
    3 "Neutral" ///
    4 "Somewhat oppose" ///
    5 "Strongly oppose"
label values hk_protest_w1 hkpro_lbl
label values hk_protest_w2 hkpro_lbl
label values hk_radical_w1 hkpro_lbl
label values hk_radical_w2 hkpro_lbl

label define interest_lbl ///
    1 "Not at all" ///
    2 "Not very" ///
    3 "Moderately" ///
    4 "Quite" ///
    5 "Very much"
label values interest_campaign_w1 interest_lbl
label values interest_campaign_w2 interest_lbl

label define concern_lbl ///
    1 "Not at all" ///
    2 "A little" ///
    3 "Some" ///
    4 "A good amount" ///
    5 "Very much"
label values concern_election_outcome_w1 concern_lbl
label values concern_election_outcome_w2 concern_lbl

label define pnews_lbl ///
    1 "None" ///
    2 "<30 minutes" ///
    3 "31–60 minutes" ///
    4 "1–1.5 hours" ///
    5 "1.5–2 hours" ///
    6 ">2 hours"
label values pnews_days_w1 pnews_lbl
label values pnews_days_w2 pnews_lbl

label define freq_lbl ///
    1 "Never" ///
    2 "Rarely" ///
    3 "Sometimes" ///
    4 "Often"
label values get_tv_news_w1 freq_lbl
label values get_tv_news_w2 freq_lbl
label values get_nwpaper_news_w1 freq_lbl
label values get_nwpaper_news_w1 freq_lbl
label values get_social_media_news_w1 freq_lbl
label values get_social_media_news_w1 freq_lbl
label values get_web_news_w1 freq_lbl
label values get_web_news_w1 freq_lbl
label values overall_polinews_consumption_w1 freq_lbl
label values overall_polinews_consumption_w2 freq_lbl

label define web7_lbl ///
    1 "Very bad/weak" ///
    7 "Very good/strong"
label values website_quality web7_lbl
label values website_strength web7_lbl

label define emotion7_lbl ///
    1 "Not at all" ///
    7 "Extremely strong"
label values positive_emotion emotion7_lbl
label values negative_emotion emotion7_lbl

label define reactance_lbl ///
    1 "Strongly disagree" ///
    2 "Somewhat disagree" ///
    3 "Neutral/Don't know" ///
    4 "Somewhat agree" ///
    5 "Strongly agree"
label values reactance reactance_lbl

label define redmedia_lbl ///
    1 "Strongly agree" ///
    2 "Agree" ///
    3 "Neutral" ///
    4 "Disagree" ///
    5 "Strongly disagree"
label values ct_rmedia redmedia_lbl

label define listgrp_lbl 0 "Control" 1 "Treatment"
label values list_exp_group listgrp_lbl


* Keep relevant variables
ds, has(varlabel)
keep `r(varlist)'

* Reorder variables for codebook
order gid wave age female location special_municipality edu full_time ///
married income_cat father_islander taoism ///
partyid spectrum pan_blue independent pan_green ///
president_2016 president_2016_voted president_2012 president_2012_voted ///
nwpaper_pref_apple sanlih_show strait_relation identity ///
turnout_w1 pres_vote_w1 vote_han_w1 vote_tsai_w1 vote_song_w1 vote_undecided_w1 ///
han_thermo_w1 tsai_thermo_w1 song_thermo_w1 relative_thermo_w1 ///
china_thermo_w1 ch_econ_inf_w1 ch_threat_w1 ch_usa_power_w1 strait_trade_w1 xidada_w1 hk_protest_w1 hk_radical_w1 prc_index_w1 ///
interest_campaign_w1 concern_election_outcome_w1 ///
get_tv_news_w1 get_nwpaper_news_w1 get_social_media_news_w1 get_web_news_w1 ///
overall_polinews_consumption_w1 pnews_days_w1 ///
conditions control placebo treatment china_times avg_browsing full_complier min_complier ///
turnout_w2 pres_vote_w2 vote_han_w2 vote_tsai_w2 vote_song_w2 ///
han_thermo_w2 tsai_thermo_w2 song_thermo_w2 relative_thermo_w2 ///
china_thermo_w2 ch_econ_inf_w2 ch_threat_w2 ch_usa_power_w2 strait_trade_w2 xidada_w2 ///
hk_protest_w2 hk_radical_w2 prc_index_w2 ///
interest_campaign_w2 concern_election_outcome_w2 get_tv_news_w2 get_nwpaper_news_w2 get_social_media_news_w2 get_web_news_w2  ///
overall_polinews_consumption_w2 pnews_days_w2 ///
website_quality website_strength positive_emotion negative_emotion reactance ct_rmedia list_exp_group itemcount ///
turnout_change vote_han_change vote_tsai_change vote_song_change relative_thermo_change ///
china_thermo_change ch_econ_inf_change ch_threat_change ch_usa_power_change strait_trade_change xidada_change hk_protest_change hk_radical_change prc_index_change


* Save final analysis data to Data subfolder
save "Data/analysis.dta", replace

* -------------------------
* CLEAN UP: Remove intermediate files
* -------------------------
* This leaves only 'analysis.dta' in the Data folder, keeping it clean.

capture erase "Data/baseline.dta"
capture erase "Data/endline.dta"
capture erase "Data/panel.dta"
capture erase "Data/tracking.dta"

exit

